package c.j.a.c.g$g;

import android.content.SharedPreferences.Editor;
import c.j.a.c.g.y;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;
import org.json.JSONObject;

/* compiled from: SharedPrefsManager */
public class g {

    /* compiled from: SharedPrefsManager */
    public class a implements Runnable {
        public final /* synthetic */ Collection a;

        public a(Collection collection) {
            this.a = collection;
        }

        public void run() {
            Objects.requireNonNull(g.this);
            Editor edit = y.a().getSharedPreferences("sp_ad_download_event", 0).edit();
            for (c.j.a.b.a.c.a aVar : this.a) {
                if (aVar != null) {
                    long j = aVar.a;
                    if (j != 0) {
                        String valueOf = String.valueOf(j);
                        JSONObject jSONObject = new JSONObject();
                        try {
                            jSONObject.put("mId", aVar.a);
                            jSONObject.put("mExtValue", aVar.b);
                            jSONObject.put("mLogExtra", aVar.c);
                            jSONObject.put("mDownloadStatus", aVar.d);
                            jSONObject.put("mPackageName", aVar.e);
                            jSONObject.put("mIsAd", aVar.n);
                            jSONObject.put("mTimeStamp", aVar.o);
                            jSONObject.put("mExtras", aVar.p);
                            jSONObject.put("mVersionCode", aVar.k);
                            jSONObject.put("mVersionName", aVar.l);
                            jSONObject.put("mDownloadId", aVar.q);
                            jSONObject.put("mIsV3Event", aVar.F);
                            jSONObject.put("mScene", aVar.N);
                            jSONObject.put("mEventTag", aVar.D);
                            jSONObject.put("mEventRefer", aVar.E);
                            jSONObject.put("mDownloadUrl", aVar.f);
                            jSONObject.put("mEnableBackDialog", aVar.r);
                            jSONObject.put("hasSendInstallFinish", aVar.J.get());
                            jSONObject.put("hasSendDownloadFailedFinally", aVar.K.get());
                            jSONObject.put("mLastFailedErrCode", aVar.y);
                            jSONObject.put("mLastFailedErrMsg", aVar.z);
                            jSONObject.put("mOpenUrl", aVar.g);
                            jSONObject.put("mLinkMode", aVar.i);
                            jSONObject.put("mDownloadMode", aVar.j);
                            jSONObject.put("mModelType", aVar.h);
                            jSONObject.put("mAppName", aVar.m);
                            jSONObject.put("mDownloadFailedTimes", aVar.s);
                            String str = "mRecentDownloadResumeTime";
                            long j2 = aVar.u;
                            if (j2 == 0) {
                                j2 = aVar.o;
                            }
                            jSONObject.put(str, j2);
                            jSONObject.put("mClickPauseTimes", aVar.t);
                            jSONObject.put("mJumpInstallTime", aVar.v);
                            jSONObject.put("mCancelInstallTime", aVar.w);
                            jSONObject.put("mLastFailedResumeCount", aVar.x);
                            jSONObject.put("mIsUpdateDownload", aVar.A);
                            jSONObject.put("mOriginMimeType", aVar.B);
                            jSONObject.put("mIsPatchApplyHandled", aVar.C);
                            jSONObject.put("downloadFinishReason", aVar.H);
                            jSONObject.put("clickDownloadTime", aVar.O);
                            jSONObject.put("clickDownloadSize", aVar.P);
                            jSONObject.put("mMimeType", aVar.G);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        edit.putString(valueOf, jSONObject.toString());
                    }
                }
            }
            edit.apply();
        }
    }

    /* compiled from: SharedPrefsManager */
    public static class b {
        public static g a = new g(null);
    }

    public g(a aVar) {
    }

    public void a(c.j.a.b.a.c.a aVar) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(aVar);
        b(arrayList);
    }

    /* JADX WARNING: Missing block: B:13:0x001b, code skipped:
            return;
     */
    public synchronized void b(java.util.Collection<c.j.a.b.a.c.a> r3) {
        /*
        r2 = this;
        monitor-enter(r2);
        if (r3 == 0) goto L_0x001a;
    L_0x0003:
        r0 = r3.isEmpty();	 Catch:{ all -> 0x0017 }
        if (r0 == 0) goto L_0x000a;
    L_0x0009:
        goto L_0x001a;
    L_0x000a:
        r0 = c.j.a.c.o.a.a;	 Catch:{ all -> 0x0017 }
        r1 = new c.j.a.c.g$g.g$a;	 Catch:{ all -> 0x0017 }
        r1.m2277init(r3);	 Catch:{ all -> 0x0017 }
        r3 = 1;
        r0.b(r1, r3);	 Catch:{ all -> 0x0017 }
        monitor-exit(r2);
        return;
    L_0x0017:
        r3 = move-exception;
        monitor-exit(r2);
        throw r3;
    L_0x001a:
        monitor-exit(r2);
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.j.a.c.g$g.g.b(java.util.Collection):void");
    }
}
